package com.ncr.travel.appmgr.style.client.gin;

import com.google.gwt.core.client.GWT;
import com.google.inject.Provider;
import com.ncr.travel.appmgr.style.client.AppManagerStyleClientBundle;

/**
 * This class is a GIN provider that manages the instantiation of the
 * AppManagerStyleClientBundle and the various style resources that it contains.
 */
public class AppManagerStyleClientBundleProvider implements Provider<AppManagerStyleClientBundle> {

	private static AppManagerStyleClientBundle dashboardStyleClientBundle;

	@Override
	public AppManagerStyleClientBundle get() {
		// Check to see if the bundle has been created before
		if (dashboardStyleClientBundle == null) {
			// The bundle hasn't been created before so create it
			dashboardStyleClientBundle = GWT.create(AppManagerStyleClientBundle.class);

			// Ensure that all of the resources have been injected
			dashboardStyleClientBundle.dashboardCss().ensureInjected();
		}

		// We have a AppManagerStyleClientBundle so return it
		return dashboardStyleClientBundle;
	}
}